﻿<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>NewMovieList</title>
    <script type="text/javascript">
        var commandHandler = function (cmd, record) {
            switch (cmd) {
                case "delete":
                    Ext.Msg.confirm('Alert', '是否确认删除?', function (btn) {
                        if (btn == "yes") {
                            dsNewMovies.remove(record);
                        }
                    });
                    break;
            }
        }
    </script>
    <style type="text/css">
        h1
        {
            font-family: MyriadPro-Semibold, 'Myriad Pro Semibold' , 'Myriad Pro' , 'Trebuchet MS' , Tahoma, arial, sans-serif;
            font-size: 250%;
            margin: 0px;
            padding: 0px;
            margin-bottom: 20px;
            text-shadow: #ccc 1px 1px 0;
        }
        .icon-delete
        {
            background-image: url(/icons/delete-png/coolite.axd) !important;
        }
    </style>
</head>
<body>
    <ext:ResourceManager runat="server" />
    <ext:Store ID="dsNewMovies" runat="server" RemoteSort="true">
        <Proxy>
            <ext:HttpProxy Url="/Admin/GetNewMovies.html" />
        </Proxy>
        <UpdateProxy>
            <ext:HttpWriteProxy Url="/Admin/SaveNewMovies.html" />
        </UpdateProxy>
        <Reader>
            <ext:JsonReader IDProperty="ID"  Root="data" TotalProperty="total">
                <Fields>
                    <ext:RecordField Name="ID" />
                    <ext:RecordField Name="MovieName" />
                </Fields>
            </ext:JsonReader>
        </Reader>
        <BaseParams>
            <ext:Parameter Name="limit" Value="15" Mode="Raw" />
            <ext:Parameter Name="start" Value="0" Mode="Raw" />
            <ext:Parameter Name="dir" Value="ASC" />
            <ext:Parameter Name="sort" Value="ID" />
        </BaseParams>
        <SortInfo Field="ID" Direction="ASC" />
    </ext:Store>
    <ext:ViewPort ID="ViewPort1" runat="server">
        <Items>
            <ext:RowLayout ID="RowLayout1" runat="server">
            <Rows>
                            <ext:LayoutRow RowHeight="0.2">
                    <ext:Panel ID="Panel1" runat="server">
                        <Content>
                            <div style="margin-left: 20px; margin-top: 20px">
                                <h1>
                                    新片编辑</h1>
                                <br />
                            </div>
                        </Content>
                    </ext:Panel>
                </ext:LayoutRow>
                <ext:LayoutRow RowHeight="0.8">
                    <ext:GridPanel ID="GridPanel1" AutoHeight="false" runat="server" Header="false" Border="false"
                        StoreID="dsNewMovies" TrackMouseOver="true" ClicksToEdit="1">
                        <ColumnModel ID="ColumnModel1" runat="server">
                            <Columns>
                                <ext:Column Sortable="false" ColumnID="ID" DataIndex="ID" Header="ID">
                                </ext:Column>
                                <ext:Column Sortable="false" ColumnID="MovieName" Width="400" DataIndex="MovieName" Header="电影名称">
                                    <Editor>
                                        <ext:TextField ID="TextField10" AllowBlank="false" runat="server" />
                                    </Editor>
                                </ext:Column>
                                
                                <ext:CommandColumn Width="25">
                                    <Commands>
                                        <ext:GridCommand CommandName="delete" Icon="delete">
                                            <ToolTip Text="删除" />
                                        </ext:GridCommand>
                                    </Commands>
                                </ext:CommandColumn>
                            </Columns>
                        </ColumnModel>
                        <SelectionModel>
                            <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" SingleSelect="true">
                            </ext:RowSelectionModel>
                        </SelectionModel>
                        <TopBar>
                            <ext:Toolbar ID="Toolbar1" runat="server">
                                <Items>
                                    <ext:Button ID="Button3" runat="server" Text="添加" Icon="Add">
                                        <Listeners>
                                            <Click Handler="var rowIndex = #{GridPanel1}.addRecord(); #{GridPanel1}.getView().focusRow(rowIndex); #{GridPanel1}.startEditing(rowIndex, 0);" />
                                        </Listeners>
                                    </ext:Button>
                                    <ext:Button ID="Button1" runat="server" Text="保存" Icon="Disk">
                                        <Listeners>
                                            <Click Handler="#{GridPanel1}.save();" />
                                        </Listeners>
                                    </ext:Button>
                                    <ext:Button ID="Button2" runat="server" Text="从排片表导入" Icon="Add">
                                        <DirectEvents>
                                            <Click Success="#{GridPanel1}.reload();" Url="/admin/NewMovieImportFromPlaytime.html"
                                                Type="Load" Method="POST" CleanRequest="true">
                                                <Confirmation ConfirmRequest="true" Title="确认" Message="确认从排片表导入?" />
                                            </Click>
                                        </DirectEvents>
                                    </ext:Button>
                                </Items>
                            </ext:Toolbar>
                        </TopBar>
                        <BottomBar>
                            <ext:PagingToolbar ID="PagingToolbar1" runat="server" StoreID="dsNewMovies" PageSize="15" />
                        </BottomBar>
                        <Listeners>
                            <Command Fn="commandHandler" />
                        </Listeners>
                        <loadmask showmask="true" Msg="加载中..." />
                        <savemask showmask="true" Msg="保存中..." />
                    </ext:GridPanel>
                </ext:LayoutRow>
            </Rows>
            </ext:RowLayout>
        </Items>
    </ext:ViewPort>
</body>
</html>
